package com.sinosoft.hydra.um.shiro;

import com.sinosoft.hydra.um.domain.permission.SysUserMember;
import com.sinosoft.hydra.um.utils.AppUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.AccessControlFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

/**
 * 用户session刷新拦截器
 *
 * @author Zhengt@sinux.com.cn
 * @time 2015-2-1
 * @desc 刷新用户session
 */
public class UserSetting extends AccessControlFilter {

    /**
     * 前置拦截
     */

    protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
        //从cookie里面拿值获取用户
        return true;
//        Subject subject = getSubject(request, response);
//        if (subject.getPrincipal() != null) {
//            return true;
//        }
//        SysUserMember member = AppUtils.getLoginUser((HttpServletRequest) request);
//        if (member != null) {
//            return true;
//        }
//        redirectToLogin(request, response);
//        return false;
    }


    protected boolean isAccessAllowed(ServletRequest arg0,
                                      ServletResponse arg1, Object arg2) throws Exception {
        return false;
    }


    protected boolean onAccessDenied(ServletRequest arg0, ServletResponse arg1)
            throws Exception {
        return false;
    }

}